﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WebDS;
using WebUS;
using WebDS.CDBNames;
using IP.Core.IPCommon;
using System.Data;
using IP.Core.IPData.DBNames;
using IP.Core.IPData;
using IP.Core.IPUserService;

public partial class ChucNang_Ban_giao_thiet_bi : System.Web.UI.Page
{
    #region bienToanCuc
    US_DM_DOT_BAO_TRI m_us_dm_dot_bao_tri = new US_DM_DOT_BAO_TRI();
    DS_DM_DOT_BAO_TRI m_ds_dm_dot_bao_tri = new DS_DM_DOT_BAO_TRI();
    #endregion

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            load_data_2_cbo_ten_ben_a();
            load_data_2_cbo_dai_dien_ben_b();
        }
    }

    private void load_data_2_cbo_ten_ben_a()
    {
        try
        {
            US_DM_DIA_PHUONG_BENH_VIEN v_us_ten_dia_phuong_benh_vien = new US_DM_DIA_PHUONG_BENH_VIEN();
            DS_DM_DIA_PHUONG_BENH_VIEN v_ds_ten_dia_phuong_benh_vien = new DS_DM_DIA_PHUONG_BENH_VIEN();
            v_us_ten_dia_phuong_benh_vien.Fill_data_ten_benh_vien(v_ds_ten_dia_phuong_benh_vien,4);
            m_cbo_ten_dia_phuong_benh_vien.DataSource = v_ds_ten_dia_phuong_benh_vien.DM_DIA_PHUONG_BENH_VIEN;
            m_cbo_ten_dia_phuong_benh_vien.DataTextField = DM_DIA_PHUONG_BENH_VIEN.TEN_DIA_PHUONG;
            m_cbo_ten_dia_phuong_benh_vien.DataValueField = DM_DIA_PHUONG_BENH_VIEN.ID;
            m_cbo_ten_dia_phuong_benh_vien.DataBind();
        }
        catch (Exception v_e)
        {

            CSystemLog_301.ExceptionHandle(this, v_e);
        }
    }

    private void load_data_2_cbo_dai_dien_ben_b()
    {
        try
        {
            US_DM_NHAN_VIEN v_us_dm_nhan_vien = new US_DM_NHAN_VIEN();
            DS_DM_NHAN_VIEN v_ds_dm_nhan_vien = new DS_DM_NHAN_VIEN();
            v_us_dm_nhan_vien.FillDataset(v_ds_dm_nhan_vien);
            m_cbo_dai_dien_ben_b.DataSource = v_ds_dm_nhan_vien.DM_NHAN_VIEN;
            m_cbo_dai_dien_ben_b.DataTextField = DM_NHAN_VIEN.TEN_NHAN_VIEN;
            m_cbo_dai_dien_ben_b.DataValueField = DM_NHAN_VIEN.ID;
            m_cbo_dai_dien_ben_b.DataBind();
        }
        catch (Exception v_e)
        {
            CSystemLog_301.ExceptionHandle(this, v_e);
        }
    }

    protected void form_2_us_object()
    {
        try
        {
            m_us_dm_dot_bao_tri.datNGAY_BAO_TRI = m_txt_ngay_bao_tri.SelectedDate;
            m_us_dm_dot_bao_tri.strNOI_THUC_HIEN_BAO_TRI = m_txt_noi_thuc_hien_bao_tri.Text;
            m_us_dm_dot_bao_tri.dcID_BEN_A = Convert.ToInt32(m_cbo_ten_dia_phuong_benh_vien.SelectedValue);
            m_us_dm_dot_bao_tri.strDAI_DIEN_BEN_A = m_txt_ten_ben_a.Text;
            m_us_dm_dot_bao_tri.strCHU_VU_DAI_DIEN_BEN_A = m_txt_chuc_vu_ben_a.Text;
            m_us_dm_dot_bao_tri.dcID_DAI_DIEN_BEN_B = Convert.ToInt32(m_cbo_dai_dien_ben_b.SelectedValue);
            m_us_dm_dot_bao_tri.strPHAN_HOI_CUA_BENH_VIEN = m_txt_phan_hoi_benh_vien.Text;
            m_us_dm_dot_bao_tri.datTHOI_GIAN_HOAN_TAT = m_txt_thoi_gian_hoan_tat.SelectedDate;
        }
        catch (Exception)
        {
            m_lbl_them_moi.Text = "";
        }
        
    }
    protected void m_btn_luu_bien_ban_lam_viec_Click(object sender, EventArgs e)
    {
        form_2_us_object();
        m_us_dm_dot_bao_tri.Insert();
        Response.Cookies["Id"].Value = m_us_dm_dot_bao_tri.dcID.ToString();
        Response.Redirect("~/ChucNang/BaoTriThietBi/Thong_tin_chung.aspx");
    }
}